<?php
$_currentPageActionClassName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $this->__REQUEST_MAPPING__)));
$_winParameter = "?parentPageId=$this->pageId&currentPageActionClassName=$_currentPageActionClassName";
?>
<script>
    $(function(){
        $("select[name='company_type']").css("display", "none");
        PageAction.currentPageActionClassName = '<?= $_currentPageActionClassName ?>';
        if (typeof PageAction[PageAction.currentPageActionClassName] == 'undefined') {
            PageAction[PageAction.currentPageActionClassName] = function() {
                var _addEditPage = PageAction.pack + '<?= $this->__REQUEST_MAPPING__ ?>Content<?= $_winParameter ?>';
                return {
                    grid : '#<?= $_GET['divId'] ?> .data_grid_wrapper .data_grid',
                    addEditPage : _addEditPage,
                    handlerUrl : PageAction.handlerRoot + 'handler/Admin.<?= str_replace('_', '.', $_currentPageActionClassName) . '.' ?>',
                    init : function() {
                        var _g = this.grid;
                        var _form = this.grid.replace(/ \.data_grid$/, '');
                        $(':input[type=submit], :radio[name=is_status]', _form).click(function(){
                            Navigation.getSearchData(_g, _form);
                        });
                        this.read();
                    },
                    read : function() {
                        $(this.grid).dataGrid({
                            url      : this.handlerUrl + 'Read',
                            //params   : [],
                            sortName : 'm.member_id',
                            sortOrder: 'DESC',
                            rp : 50,
                            buttons  : [
                                { name:'切换冻结', dbAction: { action : this.handlerUrl + 'SetFieldStatus', field : 'is_status', fieldValue : 0 }, onpress:this.setFieldStatus },
                                {separator:true},
                                <?= App\Tools\Auxi::getPowerButton('export', $this->security, $this->pageId, $this->adminPower, '批量导出') ?>
                                <?= App\Tools\Auxi::getPowerButton('add', $this->security, $this->pageId, $this->adminPower, substr($this->adminMap[$this->security]['menu'][$this->pageId]['name'], 0, -6)) ?>
                                {name:'刷 新', bclass:'refresh', onpress:Navigation.getSearchData},
                                {separator:true},
                                {name:'全 选', bclass:'set_all'},
                                {name:'反 选', bclass:'set_inv', margin:true},
                                {separator:true}
                                <?= App\Tools\Auxi::getPowerButton('delete', $this->security, $this->pageId, $this->adminPower, '删除') ?>
                            ],
                            colModel : [
                                {display:'ID',  width:60, align:'center', css:'num'},
                                {display:'用户名',  width:200, align:'center'},
                                {display:'手机号',  width:200, align:'center'},
                                {display:'性别',  width:200, align:'center'},
                                {display:'Openid',  width:100, align:'center'},
//                                {display:'头像',  width:100, align:'center'},
                                {display:'所属科室',  width:200, align:'center'},
                                {display:'常住地址',  width:200, align:'center'},
                                {display:'会员状态',  width:70, align:'center'},
                                {display:'注册时间',  width:150, align:'center'},
                                {display:'修改时间',  width:150, align:'center'},
                                {display:'操作者',  width:100, align:'center'},
                                {display:'备注',  width:150, align:'center'},

                            ],
                            useSelect : true
                            <?= App\Tools\Auxi::getPowerButton('edit', $this->security, $this->pageId, $this->adminPower) ?>
                        });
                    },
                    setFieldValue : function(t, action) {
                        Tools.doLockingUpdate(t, action, [
                            '您确定更改这',
                            '个文档属性状态吗？',
                            'directRemoveLocking',
                            '数据库出错'
                        ]);
                    },
                    setFieldStatus : function(t, action) {
                        Tools.doLockingUpdate(t, action, [
                            '您确定更改这',
                            '个显示状态吗？',
                            'directRemoveLocking',
                            '数据库出错'
                        ]);
                    },
                    exportExcel : function(t, action) {
                        var rel = $("#header dl[class=slt] dt").attr("rel");
                        var data = $("#container_" + rel.replace("/", "_")).find("form[name=search_from]").serializeArray();
                        var href = "/handler/Admin.Member.Member.DownloadExcel";
                        var i = 1;
                        for(var m in data) {
                            if (data[m].value != '') {
                                if (i == 1) {
                                    href += ("?" + data[m].name + "=" + data[m].value);
                                    i++;
                                } else {
                                    href += ("&" + data[m].name + "=" + data[m].value);
                                }
                            }
                        }
//                        console.table(href);
//                        console.table(data);
//                        return;
                        window.location.href = href;
                    },
                    add : function(t) {
                        Tools.addEditPageLoad(_addEditPage + '&action=add', 700);
                    },
                    edit : function(t) {
                        Tools.addEditPageLoad(_addEditPage + '&action=edit&id=' + t, 700);
                    },
                    readerExcel : function(t,action) {
                        Tools.uploadExcel({ uploadType : 'file', uploadName : 'file_name', mode : 'fileNameNormal', imgWidth : '150' }, t, action);
                    },
                }
            }();
            PageAction[PageAction.currentPageActionClassName].init();
        }
    });
    $("select[name='user_type']").on('change',function () {
        var sltType = $(this).val();
        if (sltType == "" || sltType == 1) {
            $("select[name='company_type']").css("display", "none");
        } else {
            $("select[name='company_type']").css("display", "");
        }
    });
</script>

<div class="data_grid_wrapper">
    <div class="control_wrapper">
        <div class="tl"></div>
        <div class="top_control">
            <div class="left"><?= $this->adminMap[$this->security]['title'] ?> » <?= $this->adminMap[$this->security]['menu'][$this->pageId]['name'] ?></div>
            <div class="control_btn"></div>
        </div>
        <div class="tr"></div>
    </div>
    <div class="grid_wrapper">
        <div class="m_search_field">
            <form name="search_from" onsubmit="return false;">
                <?= App\Admin\Helper::getDefaultSearchInfo($this->__LANGUAGE_CONFIG__) ?>
            </form>
        </div>
    </div>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="data_grid">
        <tbody>
        </tbody>
    </table>
</div>

